package com.wsj.services.impl;

import com.wsj.aop.anno.Log;
import com.wsj.services.LogService;
import org.springframework.beans.factory.InitializingBean;

/**
 * description:
 *
 * @author yang
 * @date 2019/2/19 11:44
 */
//@Service
@Log
public class LogServiceImpl implements LogService, InitializingBean {

  public LogServiceImpl() {
    System.out.println("1、执行构造函数：LogServiceImpl()...........");
  }

  //或使用@PostConstruct
  public void init() {
    System.out.println("2、容器开启，执行init-method初始化操作......................");
  }

  @Override
  public void test(String name) {
    System.out.println("执行test函数.........name:" + name);
  }

  /**
   * 初始化操作在getBean方法执行时，在doGetBean(AbstractBeanFactory)--createBean(AbstractAutowireCapableBeanFactory)--doCreateBean(AbstractAutowireCapableBeanFactory)
   * --initializeBean(AbstractAutowireCapableBeanFactory)--invokeInitMethods(AbstractAutowireCapableBeanFactory)--afterPropertiesSet()
   *
   * @author yang
   * @date 2019/3/19 21:32
   */
  @Override
  public void afterPropertiesSet() throws Exception {
    System.out.println("3、执行afterPropertiesSet初始化操作完成");
  }

  //或使用@PreDestroy
  public void destroy() {
    System.out.println("4、容器关闭，执行destroy-method销毁操作.......................");
  }
}
